<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
	
	var i=<!--[$extendResult.spaMenuTime|@count]-->;
	function addElement(){
		if(i==0){
			i = 1;
		}
		
		$('div#spaMenuElement').append('<div id="spaMenuElement'+i+'"><input name="spaMenuTime['+i+'][timeMins]" type="text" size="40" value="" /> <input name="spaMenuTime['+i+'][price]" type="text" size="40" value="" /> <a href="#" onclick="deleteElement('+i+'); return false;">delete</a></div>');
		i = i+1;
	}
	
	function deleteElement(i){
		$('div#spaMenuElement'+i).remove();
	}
	
	
</script>

<div id="stylized-form">
	<h2><!--[gt text='SpaMenu Form']--></h2>
	<form method="post" action="<!--[pnmodurl modname=spaservice type=adminform func=submit ctrl=spamenu]-->">
	<input name="form[id]" type="hidden" size="40" value="<!--[$smarty.get.id]-->" />
	<div class="wrapper-block">
		<label for="user">
			<!--[gt text='Category']-->
		</label>
		<!--[selector_object_array_ex modname=SpaService class=spacategory name=form[spaCategory_id] selectedValue=$form.spaCategory_id displayField=title]-->
	</div>
	<div class="wrapper-block">
		<label for="user">
			<!--[gt text='Tiltle']-->
		</label>
		<input name="form[title]" type="text" size="40" value="<!--[$form.title]-->" />
	</div>
	<div class="wrapper-block">
		<label for="user">
			<!--[gt text='Tiltle(Translate)']-->
		</label>
		<input name="form[titleTranslate]" type="text" size="40" value="<!--[$form.titleTranslate]-->" />
	</div>
	
	<div class="wrapper-block">
		<label for="user">
			<!--[gt text='Time & Price']-->
		</label>
		<label for="user">
			<!--[gt text='1 Item Add.']--> <a href="#" onclick="addElement();return false;"><!--[gt text="click to add"]--></a>
		</label>
		<div id="spaMenuElement">
		<!--[if isset($extendResult.spaMenuTime)]-->
		<!--[assign var="i" value="0"]-->
			<!--[foreach from=$extendResult.spaMenuTime item=spaMenuTimes]-->

					<div id="spaMenuElement<!--[$i]-->">
					<input name="spaMenuTime[<!--[$i]-->][id]" type="hidden" value="<!--[$spaMenuTimes.id]-->" />
					<input name="spaMenuTime[<!--[$i]-->][timeMins]" type="text" size="40" value="<!--[$spaMenuTimes.timeMins]-->" />
					<input name="spaMenuTime[<!--[$i]-->][price]" type="text" size="40" value="<!--[$spaMenuTimes.price]-->" />
					<a href="#" onclick="deleteElement(<!--[$i]-->); return false;">delete</a>
					</div>
					<!--[assign var="i" value=$i+1]-->
			<!--[/foreach]-->
		<!--[else]-->
			<div id="spaMenuElement0">
				<input name="spaMenuTime[0][timeMins]" type="text" size="40" value="" />
				<input name="spaMenuTime[0][price]" type="text" size="40" value="" />
			</div>
		<!--[/if]-->
		</div>
	</div>
	
	<input type="submit" value="submit">
	</form>
</div>
